import 'package:flutter/material.dart';

class LayerDialog extends Dialog {
  final title;
  final Widget infowidget;
  LayerDialog({
    Key key,
    @required this.title,
    @required this.infowidget,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    final size = MediaQuery.of(context).size;
    final height = size.height;
    return GestureDetector(
      onTap: () {
        Navigator.of(context).pop();
      },
      child: new Padding(
        padding: const EdgeInsets.fromLTRB(20.0, 20.0, 20.0, 30.0),
        child: new Material(
          type: MaterialType.transparency,
          child: new Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              GestureDetector(
                onTap: () {},
                child: new Container(
                  decoration: ShapeDecoration(
                    color: Color.fromRGBO(255, 255, 255, 1),
                    shape: RoundedRectangleBorder(
                      borderRadius: BorderRadius.all(
                        Radius.circular(6.0),
                      ),
                    ),
                  ),
                  child: Container(
                    child: Column(
                      children: <Widget>[
                        Container(
                          padding: EdgeInsets.fromLTRB(8.0, 10.0, 8.0, 0.0),
                          child: Row(
                            mainAxisAlignment: MainAxisAlignment.spaceBetween,
                            children: <Widget>[
                              SizedBox(
                                height: 30.0,
                                width: 30.0,
                              ),
                              new Text(
                                '$title',
                                style: new TextStyle(
                                  fontSize: 19.0,
                                  color: Color.fromRGBO(72, 69, 114, 1),
                                  fontWeight: FontWeight.bold,
                                ),
                              ),
                              GestureDetector(
                                onTap: () {
                                  Navigator.of(context).pop();
                                },
                                child: Container(
                                  padding: EdgeInsets.all(6.0),
                                  color: Colors.white,
                                  child: Image.asset(
                                    'images/cancel.png',
                                    width: 20.0,
                                    height: 20.0,
                                  ),
                                ),
                              ),
                            ],
                          ),
                        ),
                        Container(
                          height: 0.5,
                          width: double.infinity,
                          margin: EdgeInsets.only(top: 7.0),
                          color: Color.fromRGBO(243, 244, 248, 0.8),
                        ),
                        Container(
                          child: Container(
                            padding: EdgeInsets.only(bottom: 20.0),
                            child: ConstrainedBox(
                              constraints: BoxConstraints(
                                maxHeight: height * 0.5,
                              ),
                              child: new CustomScrollView(
                                shrinkWrap: true,
                                slivers: <Widget>[
                                  new SliverPadding(
                                    padding: EdgeInsets.fromLTRB(
                                        15.0, 0.0, 15.0, 0.0),
                                    sliver: new SliverList(
                                      delegate: new SliverChildListDelegate(
                                        <Widget>[
                                          infowidget,
                                        ],
                                      ),
                                    ),
                                  ),
                                ],
                              ),
                            ),
                          ),
                        )
                      ],
                    ),
                  ),
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
